﻿using System;
using System.ServiceModel.Channels;
using NCMIS.ObjectModel.Rest;

namespace NCMIS.ServiceModel.Syndication
{
    /// <summary>
    /// Specifies the message format to which the content type of an incomming message is mapped. Overrides the default mapping
    /// for CMIS/Atom specific content types.
    /// </summary>
    public class CmisContentTypeMapper : WebContentTypeMapper
    {
        /// <summary>
        /// Gets the message format used for a specified content type. Overrides the default mapping
        /// for CMIS/Atom specific content types.
        /// </summary>
        /// <param name="contentType">The content type that indicates the MIME type of data to be interpreted.</param>
        /// <returns>The <see cref="System.ServiceModel.Channels.WebContentFormat"/> that specifies the format to which
        /// the message content type is mapped.</returns>
        public override WebContentFormat GetMessageFormatForContentType(string contentType)
        {
            if (contentType == CmisContentType.Entry || contentType == CmisContentType.Feed || contentType == CmisContentType.Xml)
            {
                return WebContentFormat.Raw;
            }
            else
            {
                return WebContentFormat.Default;
            }
        }
    }
}
